import java.util.Scanner;

public class Solution {
    public int countKeyChanges(String s){
        int count = 0;
        int len = s.length();
        for (int i = 1; i < len; i++) {//遍历字符串，将所有的字母转化为小写字母
            if(Character.toLowerCase(s.charAt(i-1)) != Character.toLowerCase(s.charAt(i))){
                count++;//如果某个字符与上一个字符不相等，变更一次按键
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String s = in.nextLine();
            Solution solution = new Solution();
            int result = solution.countKeyChanges(s);
            System.out.println(result);
        }
    }
}
